Skip to content

Conversation

@kkent030315
Copy link
Contributor

As mentioned in this comment (#150967), this PR removes the need for the input binary by replacing it with a yaml2obj-generated file.

@llvmbot
Copy link
Member

llvmbot commented Aug 4, 2025

@llvm/pr-subscribers-llvm-binary-utilities

Author: None (kkent030315)

Changes

As mentioned in this comment (#150967), this PR removes the need for the input binary by replacing it with a yaml2obj-generated file.


Full diff: https://github.com/llvm/llvm-project/pull/151978.diff

3 Files Affected:

  • (removed) llvm/test/tools/llvm-readobj/COFF/Inputs/has-exdllcharacteristics.exe ()
  • (added) llvm/test/tools/llvm-readobj/COFF/Inputs/has-exdllcharacteristics.yaml (+75)
  • (modified) llvm/test/tools/llvm-readobj/COFF/exdllcharacteristics.test (+2-6)
diff --git a/llvm/test/tools/llvm-readobj/COFF/Inputs/has-exdllcharacteristics.exe b/llvm/test/tools/llvm-readobj/COFF/Inputs/has-exdllcharacteristics.exe
deleted file mode 100644
index 9c36817b6a474..0000000000000
Binary files a/llvm/test/tools/llvm-readobj/COFF/Inputs/has-exdllcharacteristics.exe and /dev/null differ
diff --git a/llvm/test/tools/llvm-readobj/COFF/Inputs/has-exdllcharacteristics.yaml b/llvm/test/tools/llvm-readobj/COFF/Inputs/has-exdllcharacteristics.yaml
new file mode 100644
index 0000000000000..3ee7fbe657555
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/COFF/Inputs/has-exdllcharacteristics.yaml
@@ -0,0 +1,75 @@
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 0
+  ImageBase: 0x180000000
+  SectionAlignment: 4096
+  FileAlignment: 512
+  MajorOperatingSystemVersion: 6
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 6
+  MinorSubsystemVersion: 0
+  Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ImportTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ResourceTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ExceptionTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  CertificateTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BaseRelocationTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Debug:
+    RelativeVirtualAddress: 8192
+    Size:            56
+  Architecture:
+    RelativeVirtualAddress: 0
+    Size:            0
+  GlobalPtr:
+    RelativeVirtualAddress: 0
+    Size:            0
+  TlsTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  LoadConfigTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BoundImport:
+    RelativeVirtualAddress: 0
+    Size:            0
+  IAT:
+    RelativeVirtualAddress: 0
+    Size:            0
+  DelayImportDescriptor:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ClrRuntimeHeader:
+    RelativeVirtualAddress: 0
+    Size:            0
+header:
+  Machine:         IMAGE_FILE_MACHINE_AMD64
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_DLL, IMAGE_FILE_LARGE_ADDRESS_AWARE ]
+sections:
+  - Name:            .rdata
+    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  8192
+    VirtualSize:     180
+    SectionData:     0000000091BE906800000000020000005500000058200000580400000000000091BE9068000000001400000004000000B0200000B0040000180000000380038000000000000000005020000008000000101000000300000052534453867E6BCADB53244591DEC582FAB540DB10000000433A5C55736572735C73756E675C446F63756D656E74735C636F64655C636574657865635C7836345C52656C656173655C636574657865632E706462000000008F000000
+    SizeOfRawData:   512
+symbols:         []
+...
diff --git a/llvm/test/tools/llvm-readobj/COFF/exdllcharacteristics.test b/llvm/test/tools/llvm-readobj/COFF/exdllcharacteristics.test
index ef35aea50171a..13bd6159bfd88 100644
--- a/llvm/test/tools/llvm-readobj/COFF/exdllcharacteristics.test
+++ b/llvm/test/tools/llvm-readobj/COFF/exdllcharacteristics.test
@@ -1,9 +1,5 @@
-# To regenerate has-exdllcharacteristics.exe
-# $ echo int main() { return 0; } > has-exdllcharacteristics.c
-# To make minimum possible stub file (to decrease the binary size)
-# $ echo -n '4D5A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' | xxd -r -p > stub
-# $ cl has-exdllcharacteristics.c /link /entry:main /STUB:stub /NOCOFFGRPINFO /EMITTOOLVERSIONINFO:NO /EMITPOGOPHASEINFO /NOVCFEATURE /MANIFEST:NO /cetcompat /cetcompatstrict /cetdynamicapisinproc /cetipvalidationrelaxed /hotpatchcompatible /functionpadmin:6
-RUN: llvm-readobj --coff-debug-directory %p/Inputs/has-exdllcharacteristics.exe | FileCheck %s
+RUN: yaml2obj %p/Inputs/has-exdllcharacteristics.yaml > %t.obj
+RUN: llvm-readobj --coff-debug-directory %t.obj | FileCheck %s
 
 CHECK:  DebugEntry {
 CHECK:    Characteristics: 0x0

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks generally good, thanks! One minor comment+question.

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@mstorsjo mstorsjo merged commit 421f15d into llvm:main Aug 5, 2025
9 checks passed
@@ -1,9 +1,8 @@
# To regenerate has-exdllcharacteristics.exe
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit of the comment needs updating, since it doesn't make sense in the context anymore.

@kkent030315 kkent030315 deleted the exdllchara-tests branch August 8, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants